package com.newland.esp.mapper.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newland.esp.entity.user.AuthInfoEntity;
import com.newland.esp.entity.user.UserAuthEntity;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AuthInfoMapper extends BaseMapper<AuthInfoEntity> {

    @Select("select * from user_auth")
    List<UserAuthEntity> GetAllAuth();

    @Select("select role_id from user_role where user_id = #{userId}")
    Short getRoleIdByuserId(Short userId);

    @Update("update user_info set user_id = (select user_id FROM `user_role`  where role_id = #{roleId}) where id = #{id}")
    Integer setUserId(Short id,Short roleId);

    @Select("select * from auth_info")
    List<AuthInfoEntity> GetAllAuthInfo();

    List<AuthInfoEntity> getUserAuthList();

//    List<AuthInfoEntity> getRoleAuthListByauthIds(List ids);
    List<AuthInfoEntity> getRoleAuthListByRoleId(Short roleId);
}
